
  
clear  
 
 * Mexican census 
 
 use  "${data}Mexcensus2020_final.dta" if  sexo==1  &  inrange(age,18,25) 
 
 *SINGLE , born in Mexico 
   keep if  situa_conyugal==8  
    rename ent_pais_nac birth_place
     keep if  inrange(birth_place ,1,32)==1 

	 
  g secondary_less= inlist(nivacad,0,2,3)
  g upper_secon= inlist(nivacad,4,5,6,7,8,9)
    g sometertiary= inrange( nivacad,10,14) 


    g 		region_birth = 1 if inlist(birth_place ,2,3, 8,5,10,19,25,26,28)
	replace region_birth= 2 if inlist(birth_place ,15,9,11,17,22,24,32)
	replace region_birth= 3 if inlist(birth_place ,1,6,12,14,16,18)
	replace region_birth= 4 if inlist(birth_place ,13,21,29,30)
	replace region_birth= 5 if region_birth==.
	
	
	label define rrbirth 1 "north" 2 "center" 3 "west" 4 "east" 5 "south" , modify 
	label values region_birth  rrbirth 
	
	label define living_area_lbl 1 "Ciudad" ///
                             2 "Pueblo" ///
                             3 "Zona rural", modify
							 
	g living_area= 1 if inlist(tamloc,5,4)
	replace living_area= 2 if inlist(tamloc,2,3)
	replace living_area= 3 if inlist(tamloc,1)
	label values   living_area living_area_lbl 
	
	ta region_birth, gen(region_birth_)	
	ta living_area, gen( living_area_)
	
	g work=  inrange(conact,10,20)
	g lookjob=  inlist(conact,30)
	g studying=  inlist(conact,50)
	g hh_chore= inlist(conact,60)
	
global dependent  secondary_less upper_secon sometertiary  work lookjob studying hh_chore  ///
	region_birth_1 region_birth_2 region_birth_3 region_birth_4  living_area_1  living_area_2 living_area_3 
	
	
	 	foreach y of varlist  $dependent    {
			replace `y'= 100*`y'
		}	
	
		label var living_area_1 "Living in a city"
	label var living_area_2 "Living in a town"
	label var living_area_3 "Living in rural area"
	
	label  var  secondary_less "Secondary eductaion or less"
	label var upper_secon  "Upper secondary education"
	label var sometertiary  "Tertiary education"
	label var work  "Employment status: working"
	label var lookjob "Employment status: looking for a job"
	label var studying  "Employment status: Currently studying"
	label var hh_chore "Employment status:household chores "

	label var region_birth_1  "Region of birth: North Mexico" 
	label var region_birth_2   "Region of birth: Center Mexico" 
    label var region_birth_3  "Region of birth: West Mexico" 
    label var region_birth_4   "Region of birth: East Mexico" 
    label var region_birth_5   "Region of birth: South" 
	

	qui eststo  desc1  : estpost tabstat  $dependent  [fw=factor] , statistics(n mean    ) columns(statistics) 	

	
* Online Survey 

	use "${source}online_survey_dataset.dta", clear 
	
	global dependent  secondary_less upper_secon sometertiary  work lookjob studying hh_chore  ///
	region_birth_1 region_birth_2 region_birth_3 region_birth_4  living_area_1  living_area_2 living_area_3 
	
	
	 	foreach y of varlist  $dependent    {
			replace `y'= 100*`y'
		}	
			
	qui eststo  desc0  : estpost tabstat  $dependent   , statistics(n mean    ) columns(statistics) 	

	
			
	nois esttab desc0 desc1   using "${result}TableC6.smcl"  , label replace mtitles("survey" "census")  ///
		cells( `"mean( fmt(1) pattern(1 ) )"' `""' )  varwidth(40) title(Table C.6)

	
			
	
	